package com.acme.domain.bank;

import com.acme.domain.account.Account;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

public class Client implements Serializable {
    private String name;
    private Gender gender;
    private List<Account> accounts = new LinkedList<Account>();

    public Client(String name, Gender gender) {
        this.name = name;
        this.gender = gender;
    }

    public void addAccount(Account account) {
        accounts.add(account);
    }

    public String getName() {
        return name;
    }

    public Gender getGender() {
        return gender;
    }

    public List<Account> getAccounts() {
        return accounts;
    }

    @Override
    public String toString() {
        return "Client{" +
                "name='" + name + '\'' +
                ", gender=" + gender +
                ", accounts=" + accounts +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Client client = (Client) o;

        if (gender != client.gender) return false;
        if (name != null ? !name.equals(client.name) : client.name != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = name != null ? name.hashCode() : 0;
        result = 31 * result + (gender != null ? gender.hashCode() : 0);
        return result;
    }
}